package com.zhuangjie.shop.feign;

import com.zhaungjie.base.conduit.R;
import com.zhaungjie.base.conduit.TypeR;
import com.zhuangjie.user.entity.AddressBook;
import com.zhuangjie.user.vo.AddressBookVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

@Component
@FeignClient(name = "spark-user",path = "/user")
public interface UserFeignService {
    @GetMapping("/address-book/{addressBookId}")
        // @FeignRetry(maxAttempt = 4, retryInterval = 200)
    TypeR<AddressBook> getUserAddressBookById(@PathVariable("addressBookId") Long addressBookId);


    @ApiOperation("根据请求携带的店铺经纬度，获取合适的地址，如果没有适合的将返回null")
    @GetMapping("/address-book/preferred-address")
    TypeR<AddressBookVO> preferredAddress(@RequestParam("longitude") Double longitude,
                                          @RequestParam("latitude") Double latitude,
                                          @RequestParam("businessScope") Double businessScope) throws Exception;


    @ApiOperation("根据id获取当前用户地址信息")
    @GetMapping("/address-book/{addressBookId}")
    TypeR<AddressBook> getAddressBookById(@PathVariable("addressBookId") Long addressBookId);

}
